<template>
  <div class="panel">
    <h3>图谱基本信息</h3>
    <el-descriptions :column="1" border>
      <el-descriptions-item label="节点数量">{{ stats.node_count }}</el-descriptions-item>
      <el-descriptions-item label="边数量">{{ stats.edge_count }}</el-descriptions-item>
      <el-descriptions-item label="节点类型">{{ stats.labels?.join(', ') }}</el-descriptions-item>
    </el-descriptions>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'

const stats = ref({ node_count: 0, edge_count: 0, labels: [] })

onMounted(async () => {
  const res = await fetch('http://127.0.0.1:8000/stats') // 注意后端地址
  stats.value = await res.json()
})
</script>